<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link type="text/css" rel="stylesheet" href="main.css">
    <!--jquery -->
	<script type="text/javascript" src="../js/jquery/jquery-2.0.3.min.js" ></script>
	
	<script type="text/javascript" src="../js/share.js"></script>
<!-- 	<script type="text/javascript" src="11.js" ></script> -->
	
	<script type="text/javascript">
	var itemno = "";
	var applyid = "";
	var nodeno = "";
	var orgcode = "";
	var nextnodecode1 = "";
	var selectID = "userlist";
	var applyno = "";

	$(function(){
		applyno = getUrlParam("applyno");
		bindApply(applyno);
	})


	function bindApply(applyno){
		$.ajax({ 
			url: basePath() + 'business/getapplyinfo.do',
			data: {"applyno": applyno},
			dataType: "json",
	        contentType: "application/json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonApply = data.datas;
//		    		var jsonBusiness = data.datas.business;
//		    		var jsonMaterial = data.datas.material;
		    		
		    		bindApplyForm(jsonApply);
		    		
		    		//绑定业务资料
		    		bindBusinessForm(jsonApply['applyid'], jsonApply['itemno']);
					
		    		
//		    		//绑定附件材料
		    		bindMaterialListForm(jsonApply['applyid']);	 

					//绑定设备及主要技术参数
					bindDevice(jsonApply['applyid']);
		    	}
	      	}
		});
	}

	function bindApplyForm(jsonApply){
		$('#proposer').html(jsonApply['proposer']);
		
		for(var d in jsonApply){//遍历json对象的每个key/value对,p为key
			if(d == 'applytime'){
				$('#' + d).html(formatDate(jsonApply[d], 'yyyy-mm-dd hh:mi'));
			}
			else if(d == 'nodename'){
				if(jsonApply[d] == '办结')
					$('#' + d).html('<span style="color:green;font-weight: bold;">' + jsonApply[d] + '</span>');
				else if(jsonApply[d].indexOf('补正') >= 0){
					$('#' + d).html('<span style="color:red;font-weight: bold;">' + jsonApply[d] + '</span>');
					$('#correction').show();
					$('#correction').attr('href', 'correction.html?applyno=' + applyno);
				}
				else if(jsonApply[d].indexOf('申报') >= 0){
					$('#' + d).html('<span style="color:red;font-weight: bold;">未提交</span>');
					$('#edit').show();
					$('#edit').attr('href', 'edit.html?applyno=' + applyno);
				}
	        	else if(jsonApply[d].indexOf('受理') >= 0)
	        		$('#' + d).html('<span style="color:blue; font-weight: bold;">待受理</span>');
				else{
					$('#' + d).html('<span style="color:blue;font-weight: bold;">已受理</span>');
				}
			}
			else{
				$('#' + d).html(jsonApply[d] == '' ? '/' : jsonApply[d]);
			}
		}
	}

	function bindBusinessForm(applyid, itemno){
		var oldapplyid='';
		$.ajax({ 
			url: basePath() + 'business/getbusinessinfo.do',
			data: {"applyid": applyid, "itemno": itemno},
			dataType: "json",
			async: false, 
	        contentType: "application/json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonBusiness = data.datas;
					
		    		for(var d in jsonBusiness){//遍历json对象的每个key/value对,p为key
		    			if(d=='oldapplyid'){
							oldapplyid=jsonBusiness[d];
						}
		    			if(d == 'workbegintime' || d == 'workendtime'){
		    				$('#' + d).html(formatDate(jsonBusiness[d], 'yyyy-mm-dd'));
		    			}
		    			else{
		    				$('#' + d).html(jsonBusiness[d] == '' ? '/' : jsonBusiness[d]);
		    			}
		    		}
		    	}
	      	}
		});
		$.ajax({ 
			url: basePath() + 'business/getbusinessinfo.do',
			data: {"applyid": oldapplyid, "itemno": itemno},
			dataType: "json",
	        contentType: "application/json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonBusiness = data.datas;
					var oldworktime ="";
					oldworktime=formatDate(jsonBusiness["workbegintime"], 'yyyy-mm-dd')+"至"+formatDate(jsonBusiness["workendtime"], 'yyyy-mm-dd');
					$('#oldworktime').html(oldworktime);
					$('#olddevicename').html(jsonBusiness['devicename']);
					$('#oldtechnicalparameter').html(jsonBusiness['technicalparameter']);
		    	}
	      	}
		});
		$.ajax({ 
			url: basePath() + 'business/getshipinfo.do?applyid='+oldapplyid,
			dataType: "json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonDevice = data.datas;
					for(var i = 0; i < jsonDevice.length; i++){
						var shipname = jsonDevice[i]['shipname'];
						var technicalparameter = generator(jsonDevice[i]);
						$("#nowdevicetr").before('<tr><td class="td-15"><span>'+shipname+'</span></td><td colspan="3" align="center"><span>'+technicalparameter+'</span></td></tr>');
					}
		    	}
	      	}
		});
		
	}
	
	function generator(jsonDevice){
		var builddate = formatDate(jsonDevice["builddate"], 'yyyy-mm-dd');
		var technicalparameter = "总吨位:"+jsonDevice['grosstonnage']+",净吨位:"+jsonDevice['nettonnage']+",总功率:"+jsonDevice['enginepower']+",客位:"+jsonDevice['ratedseat']+",总长:"+jsonDevice['overalllength']+",型宽:"+jsonDevice['mouldedbreadth']+",型深:"+jsonDevice['mouldeddepth']+",建造日期:"+builddate+",所有人:"+jsonDevice['owner']+",经营人:"+jsonDevice['operator'];
		return technicalparameter;
	}
	
	function bindMaterialListForm(applyid){

		$.ajax({ 
			url: basePath() + 'business/getmaterialinfo.do',
			data: {"applyid": applyid},
			dataType: "json",
	        contentType: "application/json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonMaterial = data.datas;

					var k = 1;
					for(var i = 0; i < jsonMaterial.length; i++){
						var materialname = jsonMaterial[i]['materialname'];
						
						var fileid=jsonMaterial[i]['fileid']
						if('' != fileid){
							var materialnameHmtl = k + '、' + materialname + '<br />';
							$('#material').append(materialnameHmtl);
							k++;
						}
					}
		    	}
	      	}
		});
	}

	function bindDevice(applyid){
		$.ajax({ 
			url: basePath() + 'business/getshipinfo.do?applyid='+applyid,
			dataType: "json",
			success: function(data){
		    	if(data.result == 1){
		    		var jsonDevice = data.datas;
					for(var i = 0; i < jsonDevice.length; i++){
						var shipname = jsonDevice[i]['shipname'];
						var technicalparameter = generator(jsonDevice[i]);
						$("#materialtr").before('<tr><td class="td-15"><span>'+shipname+'</span></td><td colspan="3" align="center"><span>'+technicalparameter+'</span></td></tr>');
					}
		    	}
	      	}
		});
	}
	</script>
    <style>
        table{
            border-style: solid;
            border-width: 1px;
            border-color: black;
            border-collapse: collapse;
        }
    </style>
    <title>水上水下活动变更申请书</title>
</head>
<body>
<div class="mainBody">
    <p style="font-size: 23px;margin-top: 140px;letter-spacing: 20px">中华人民共和国</p>
    <p style="font-size: 23px;margin-top: 70px">水上水下活动变更</p>
    <p style="font-size: 30px;font-weight: bold;margin-top:150px;letter-spacing: 10px ">申请书</p>
    <p style="font-size: 32px;margin-top:380px;">中华人民共和国海事局监制</p>
</div>
<div class="mainBody1">
    <p style="display: inline;margin-left: 500px;margin-top: 130px;height: 30px;">编号：</p> 
    <p id='applyno' style="display: inline;margin-left: 10px;"></p>
    <p style="display: inline;"></p>
</div>
<div>
    <table border="1"  align="center" cellspacing="0" cellpadding="0" style="border-style: solid;border-width: 1px;border-color: black;border-collapse: collapse;">
        <tr>
            <td class="td-15">项目名称</td>
            <td class="td-16"><span id="itemname"></span></td>
            <td class="td-15">活动开始日期</td>
            <td class="td-16"><span id="workbegintime"></span></td>
        </tr>
        <tr>
            <td class="td-15">建设单位</td>
            <td class="td-16"><span id="buildunitname" style="margin-left: 10px;"></td>
            <td class="td-15">预计活动结束日期</td>
            <td class="td-16"><span id="workendtime"></td>
        </tr>
        <tr>
            <td class="td-15">原许可证<br>有效期</td>
            <td class="td-16"><span id="oldworktime" style="margin-left: 10px;"></td>
            <td class="td-15">申请延续期限</td>
            <td class="td-16"></td>
        </tr>
        <tr>
            <td class="td-15">活动主办单位/<br>施工单位</td>
            <td colspan="3"><span id="workunitname" style="margin-left: 10px;"></td>
        </tr>
        <tr>
            <td class="td-15">地点范围</td>
            <td colspan="3"><span id="workarea" style="margin-left: 10px;"></td>
        </tr>
        <tr>
            <td colspan="4" align="center" height="40px">原许可水上水下活动作业船舶及设备</td>
        </tr>
        <tr>
            <td class="td-15">名称</td>
            <td colspan="3" align="center">主要技术参数</td>
        </tr>
        <tr>
            <td class="td-15"><span id="olddevicename"></td>
            <td colspan="3" align="center"><span id="oldtechnicalparameter"></span></td>
        </tr>
        <tr id="nowdevicetr">
            <td colspan="4" align="center" height="40px">变更后水上水下活动作业船舶及设备</td>
        </tr>
        <tr>
            <td class="td-15">名称</td>
            <td colspan="3" align="center">主要技术参数</td>
        </tr>
        <tr>
            <td class="td-15"><span id="devicename"></span></td>
            <td colspan="3" align="center"><span id="technicalparameter"></span></td>
        </tr>
        <tr id="materialtr">
            <td colspan="4" height="250px" valign="top" align="left" >附送材料：
	            <br />
	            <span id="material"></span>
            </td>
        </tr>
        <tr>
            <td colspan="4" height="140px" align="left" >
                <div style="height: 30px;">
                    <p style="display: inline;margin-left: 15px;">联系人：</p>
                    <p id='proposer' style="display: inline;margin-left: 0px;"></p>
                    <p style="display: inline;"></p>
                    <p style="display: inline;margin-left: 300px;">申请单位：（章）</p>
                </div>
                <div style="height: 20px">
                    <p style="display: inline;margin-left: 15px;">联系电话：</p>
                    <p id='mobilephone' style="display: inline;margin-left: 10px;"></p>
                    <p style="display: inline;margin-left: 15px;"></p>
                    <p style="display: inline;margin-left: 187px;">申请日期：</p>
                    <p id='applytime' style="display: inline;margin-left: 10px;"></p>
                    <p style="display: inline;margin-left: 15px;"></p>
                </div>
            </td>
        </tr>
    </table>
</div>
</body>
</html>